package com.company.finance.ddd.common;

import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 *
 * @author wanglei
 * @version $$Id: SpringBeanContext, v 0.1 2021/2/9 14:47 wanglei Exp $$
 */
@Getter
@Component
public class SpringBeanContext implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    private SpringBeanContext(){
    }

    @Override
    public void setApplicationContext(@NotNull ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
        return new RestTemplate();
    }
}
